package wang.hu.bos.service.transit.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import wang.hu.bos.dao.WayBillDao;
import wang.hu.bos.dao.index.WayBillIndexDao;
import wang.hu.bos.dao.transit.SignInfoDao;
import wang.hu.bos.dao.transit.TransitDao;
import wang.hu.bos.domain.transit.SignInfo;
import wang.hu.bos.domain.transit.TransitInfo;
import wang.hu.bos.service.transit.SignInfoService;

@Service
@Transactional
public class SignInfoServiceImpl implements SignInfoService {
	@Autowired
	private SignInfoDao signInfoDao;
	@Autowired
	private TransitDao transitDao;
	@Autowired
	private WayBillDao wayBillDao;
	@Autowired
	private WayBillIndexDao wayBillIndexDao;

	@Override
	public void save(String transitInfoid, SignInfo signInfo) {
		signInfoDao.save(signInfo);
		TransitInfo transitInfo = transitDao.findOne(Integer
				.parseInt(transitInfoid));
		transitInfo.setSignInfo(signInfo);
		if (signInfo.getSignType().equals("正常")) {
			transitInfo.setStatus("正常签收");
			transitInfo.getWayBill().setSignStatus(3);
			wayBillIndexDao.save(transitInfo.getWayBill());
		} else {
			transitInfo.setStatus("异常");
			transitInfo.getWayBill().setSignStatus(4);
			wayBillIndexDao.save(transitInfo.getWayBill());
		}

	}

}
